package mi.payment.constants;

import android.content.res.Resources;

import java.util.HashMap;
import java.util.Map;

import mi.payment.MyApplication;
import mi.payment.R;
import mi.payment.settings.SystemParamsSettings;
import mi.payment.settings.SystemParamsOperation;

/**
 * Created by Administrator on 2016/6/20.
 */
public class TransType {
    private static final Map transtypes = new HashMap<String, String>();

    private static final Map transtypeDes = new HashMap<String, String>();

    public static void init() {
        initMap();
    }

    public static void initTranstypeDes() {
        SystemParamsSettings systemParamsSettings = SystemParamsOperation.getInstance().getSystemParamsSettings();
        initTranstypeDesMap();
    }


    public static String getName(String code) {
        if (transtypes.isEmpty()) {
            init();
        }

        if (transtypes.containsKey(code)) {
            return (String) transtypes.get(code);
        } else {
            return code;
        }
    }

    public static String getTransTypeDes(int transPlatform, int transType) {
        if (transtypeDes.isEmpty()) {
            initTranstypeDesMap();
        }
        String type = String.valueOf(transPlatform) + transType;
        if (transtypeDes.containsKey(type)) {
            return (String) transtypeDes.get(type);
        } else {
            return type;
        }
    }

    private static void initTranstypeDesMap() {
        Resources resources = MyApplication.getInstance().getResources();
        transtypeDes.put("01", resources.getString(R.string.transtypes22));
        transtypeDes.put("02", resources.getString(R.string.transtypes23));
        transtypeDes.put("03", resources.getString(R.string.transtypes25));
        transtypeDes.put("04", resources.getString(R.string.transtypes10));
        transtypeDes.put("05", resources.getString(R.string.transtypes11));
        transtypeDes.put("06", resources.getString(R.string.transtypes20));
        transtypeDes.put("07", resources.getString(R.string.transtypes21));
        transtypeDes.put("11", resources.getString(R.string.transtypesAL));
        transtypeDes.put("12", resources.getString(R.string.transtypesAR));
        transtypeDes.put("13", resources.getString(R.string.transtypesAR));
        transtypeDes.put("21", resources.getString(R.string.transtypesWX));
        transtypeDes.put("22", resources.getString(R.string.transtypesWR));
        transtypeDes.put("23", resources.getString(R.string.transtypesWR));
//        transtypeDes.put("31", resources.getString(R.string.transtypes32));
//        transtypeDes.put("32", resources.getString(R.string.transtypes34));
//        transtypeDes.put("33", resources.getString(R.string.transtypes36));
        transtypeDes.put("41", resources.getString(R.string.transtypesUX));
        transtypeDes.put("42", resources.getString(R.string.transtypesUR));
        transtypeDes.put("43", resources.getString(R.string.transtypesUR));

    }


    private static void initMap() {
        Resources resources = MyApplication.getInstance().getResources();
        transtypes.put("00", resources.getString(R.string.transtypes00));
        transtypes.put("01", resources.getString(R.string.transtypes01));
        transtypes.put("03", resources.getString(R.string.transtypes03));
        transtypes.put("10", resources.getString(R.string.transtypes10));
        transtypes.put("11", resources.getString(R.string.transtypes11));
        transtypes.put("20", resources.getString(R.string.transtypes20));
        transtypes.put("21", resources.getString(R.string.transtypes21));
        transtypes.put("22", resources.getString(R.string.transtypes22));
        transtypes.put("23", resources.getString(R.string.transtypes23));
        transtypes.put("24", resources.getString(R.string.transtypes24));
        transtypes.put("25", resources.getString(R.string.transtypes25));
        transtypes.put("27", resources.getString(R.string.transtypes27));
        transtypes.put("30", resources.getString(R.string.transtypes30));
        transtypes.put("32", resources.getString(R.string.transtypes32));
        transtypes.put("34", resources.getString(R.string.transtypes34));
        transtypes.put("36", resources.getString(R.string.transtypes36));
        transtypes.put("40", resources.getString(R.string.transtypes40));
        transtypes.put("41", resources.getString(R.string.transtypes41));
        transtypes.put("42", resources.getString(R.string.transtypes42));
        transtypes.put("45", resources.getString(R.string.transtypes45));
        transtypes.put("46", resources.getString(R.string.transtypes46));
        transtypes.put("47", resources.getString(R.string.transtypes47));
        transtypes.put("48", resources.getString(R.string.transtypes48));
        transtypes.put("49", resources.getString(R.string.transtypes49));
        transtypes.put("51", resources.getString(R.string.transtypes51));
        transtypes.put("53", resources.getString(R.string.transtypes53));
        transtypes.put("54", resources.getString(R.string.transtypes54));

        transtypes.put("10c", resources.getString(R.string.transtypes10));
        transtypes.put("11c", resources.getString(R.string.transtypes11));
        transtypes.put("20c", resources.getString(R.string.transtypes20));
        transtypes.put("21c", resources.getString(R.string.transtypes21));
        transtypes.put("22c", resources.getString(R.string.transtypes22));
        transtypes.put("23c", resources.getString(R.string.transtypes23));
        transtypes.put("24c", resources.getString(R.string.transtypes24));
        transtypes.put("25c", resources.getString(R.string.transtypes25));

        transtypes.put("10e", resources.getString(R.string.transtypes10_e1));
        transtypes.put("11e", resources.getString(R.string.transtypes11_e1));
        transtypes.put("20e", resources.getString(R.string.transtypes20_e1));
        transtypes.put("21e", resources.getString(R.string.transtypes21_e1));
        transtypes.put("22e", resources.getString(R.string.transtypes22_e1));
        transtypes.put("23e", resources.getString(R.string.transtypes23_e1));
        transtypes.put("24e", resources.getString(R.string.transtypes24_e1));
        transtypes.put("25e", resources.getString(R.string.transtypes25_e1));

        transtypes.put(TransShortType.AL, resources.getString(R.string.transtypesAL));
        transtypes.put(TransShortType.AD, resources.getString(R.string.transtypesAD));
        transtypes.put(TransShortType.AR, resources.getString(R.string.transtypesAR));
        transtypes.put(TransShortType.WX, resources.getString(R.string.transtypesWX));
        transtypes.put(TransShortType.WD, resources.getString(R.string.transtypesWD));
        transtypes.put(TransShortType.WR, resources.getString(R.string.transtypesWR));
    }

}
